package com.itheima.service.system.dept.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.system.dept.DeptDao;
import com.itheima.domain.system.dept.Dept;
import com.itheima.service.system.dept.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptDao deptDao;

    @Override
    public List<Dept> findAll(String companyId) {
        return deptDao.findAll(companyId);
    }

    @Override
    public PageInfo<Dept> findAll(String companyId, int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Dept> all = deptDao.findAll(companyId);
        return new PageInfo<>(all);
    }

    @Override
    public void save(Dept dept) {
        deptDao.save(dept);
    }

    @Override
    public void update(Dept dept) {
        deptDao.update(dept);
    }

    @Override
    public void delete(String id) {

        deptDao.delete(id);
    }

    @Override
    public Dept findById(String id) {
        return deptDao.findById(id);
    }
}
